/********************************************************************************
 * Project Name		[JavaEE_Web]
 * File Name     	[PersonBean.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package listener;

import java.io.Serializable;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;

import _notes.servlet.Servlet04;

/**
 * 测试Session的钝化和活化<br/>
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * @see {@linkplain Servlet04#sessionPersistence SesssionPersistence}
 * 
 */
public class PersonBean implements HttpSessionActivationListener, Serializable {

	private static final long serialVersionUID = 7579137708039556204L;

	private String name;

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public PersonBean() {
	}

	public PersonBean(String name) {
		this.name = name;
	}

	@Override
	public void sessionWillPassivate(HttpSessionEvent se) {
		System.out.println(name + "和session一起被序列化[钝化]到硬盘了, session的id是: " + se.getSession().getId());
	}

	@Override
	public void sessionDidActivate(HttpSessionEvent se) {
		System.out.println(name + "和session一起从硬盘反序列化[活化]回到内存了, session的id是: " + se.getSession().getId());
	}
}
